import alert from '../src/main/Modal/alert';
import { close,open } from '../src/main/Modal/core';
import loading from '../src/main/Modal/loading';
import readme from '../src/main/Modal/readme';
import tips from '../src/main/Modal/tips';
import { localStorage } from '../src/main/Storage';
import Util from '../src/main/util';

const global = require('../src/main/global');

// 测试用例上需要补充的在这里添加
window.WPT.Util = {};
window.WPT.Modal = {};

WPT.Util = Util;
WPT.Modal.alert = alert;
WPT.Modal.readme = readme;
WPT.Modal.loading = loading;
WPT.Modal.open = open;
WPT.Modal.close = close;
WPT.Modal.tips = tips;
WPT.localStorage = localStorage;

if (global.onTouchEnd) {
    Object.assign(WPT, global);
}

if (process.argv[3]) {
    const Name = process.argv[3].split('=')[1];
    // 运行单个用例需要按需加载文件
    // if (Name.indexOf('Countdown') > -1) {
    //     const global = require('../src/main/global');
    //     WPT.Interval = global.Interval;
    // }
} else {
    // global = require('../src/main/global');
    // WPT.Interval = global.Interval;
    // WPT.onTouchEnd = global.onTouchEnd;
}


WPT.getData = (url, data, callback) => {
    callback({ code: 0, status: 200 });
    return { url, data };
};

WPT.postData = (url, data, callback) => {
    callback({ code: 0 });
    return { url, data };
};

WPT.showPage = url => url;

WPT.replaceUrl = url => url;

const os = {
    ios: true,
};

const onTouchEnd = WPT.onTouchEnd;

export default WPT;

export { os, onTouchEnd };
